package HandleMessage

import (
	__ "beego_base_demo/protobuf"
	"beego_base_demo/server"
	"beego_base_demo/tcpCon"
	"fmt"
	"github.com/golang/protobuf/proto"
	"net"
)

func HandleMessage(conn net.Conn,data []byte) {
	request:=&__.Packet{}
	response:=&__.Packet{}

	err := proto.Unmarshal(data, request)
	if err != nil {
		fmt.Println(err)
		return
	}
	//消息处理就这么做吧 server开启的时候注册一下
	server.HandlePacket(request,response)
	if response.Marshal_!=nil{
		marshal, err := proto.Marshal(response)
		if err != nil {
			return
		}
		tcpCon.Write(conn,marshal)
	}
}
